#define _CRT_SECURE_NO_WARNINGS 1
/**
*      author: Y_Yao
*      created: 2024-10-24 17:20:21
**/

#include<bits/stdc++.h>

using namespace std;
#define int LL
using LL = long long;
const LL LLINF = 1e18;
const int INF = 0x3f3f3f3f;
const int N = 2e5 + 7;
int a[N];
int n, k, sum, mx;

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    cin >> t;
    while (t--)
    {
        cin >> n >> k;
        sum = 0, mx = -INF;
        for (int i = 1;i <= n;i++)
        {
            cin >> a[i];
            sum += a[i];
            mx = max(mx, a[i]);
        }

        for (int i = n;i > 0;i--)
        {
            int len = (sum + k) / i;
            if (len * i - sum < 0) continue;
            if (len * i - sum <= k && len >= mx)
            {
                cout << i << endl;
                break;
            }
        }
    }
    return 0;
}